/**
	* <p><code>Circular</code> Circular easing function, adopted from robertpenner.com.</p>
	* 
	* This software is derived from code bearing the copyright notice,
	*
	* Copyright © 2001 Robert Penner
  * All rights reserved.
  *
  * and governed by terms of use at http://www.robertpenner.com/easing_terms_of_use.html
  * 
	* @version 1.0
	*
	* 
	*/

package singularity.easing;

  class Circular extends Easing {
    
    public function new()
    {
      super();
      
      __type = Easing.CIRCULAR;
    }
    
	  public override function easeIn (t:Float, b:Float, c:Float, d:Float, ?optional1:Float=0, ?optional2:Float=0):Float 
	  {
		   return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	  }
	   
	  public override function easeOut (t:Float, b:Float, c:Float, d:Float, ?optional1:Float=0, ?optional2:Float=0):Float 
	  {
		   return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	  }
	   
	  public override function easeInOut (t:Float, b:Float, c:Float, d:Float, ?optional1:Float=0, ?optional2:Float=0):Float 
	  {
		   if ((t/=d/2) < 1)
		   {
		     return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		   }
		   else
		   {
		     return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
		   }
	  }
	}
